package com.yanboo.modules.mnt.domain;

import com.yanboo.common.base.BaseEntity;
import com.yanboo.constant.ProcessorStatus;
import jakarta.persistence.*;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import java.io.Serializable;

/**
 * @description /
 * @author fdq
 * @date 2024-03-27
 **/
@Entity
@Getter
@Setter
@Accessors(chain = true)
@DynamicInsert
@DynamicUpdate
@Table(name="[sys_processor]")
@Schema(description = "sys_processor")
public class Processor extends BaseEntity implements Serializable {


    @Column(name = "[command]")
    @Schema(description = "命令")
    private String command;


    @Column(name = "[pid]")
    @Schema(description = "进程id")
    private Long pid;


    @Column(name = "[status]")
    @Schema(description = "状态")
    @Enumerated(EnumType.STRING)
    private ProcessorStatus status;


    @Column(name = "[name]")
    @Schema(description = "名称")
    private String name;


    @Column(name = "[target_status]")
    @Schema(description = "目标状态")
    @Enumerated(EnumType.STRING)
    private ProcessorStatus targetStatus;


    @Column(name = "[description]")
    @Schema(description = "描述")
    private String description;

    public void copy(Processor source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
